@extends('default.layouts.adminPublic')
@section('title', '添加用户')

@section('content')
<!--导航开始-->
<div class="crumb_warp">
    <i class="fa fa-home"></i> <a href="{{url('admin')}}">首页</a> &raquo; 用户管理
</div>
<!--导航结束-->

<!--结果集标题与导航组件 开始-->
<div class="result_wrap">
    <div class="result_title">
        <h3>添加用户</h3>
        @if(count($errors)>0)
            <div class="mark">
                @if(is_object($errors))
                    @foreach($errors->all() as $error)
                        <p>{{$error}}</p>
                    @endforeach
                @else
                    <p>{{$errors}}</p>
                @endif
            </div>
        @endif
        @include('flash::message')
    </div>
    <div class="result_content">
        <div class="short_wrap">
            <a href="{{url('admin/admin_user/create')}}"><i class="fa fa-plus"></i>添加用户</a>
            <a href="{{url('admin/admin_user')}}"><i class="fa fa-recycle"></i>用户列表</a>
        </div>
    </div>
</div>
<!--结果集标题与导航组件 结束-->

<div class="result_wrap">
    <form action="{{url('admin/admin_user')}}" method="post"  method="post"  name="userForm"
          id="userForm" onsubmit="return checkForm('#userForm')">
        {{csrf_field()}}
        <table class="add_tab">
            <tbody>
            <tr>
                <th width="120">超级管理员：</th>
                <td>
                    <select name="is_super" style="width:200px;">
                        <option value="1" {{ old('is_super') == 1 ? 'selected':'' }}>是</option>
                        <option value="0" {{ old('is_super') == 0 ? 'selected':'' }}>否</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th><i class="require">*</i> 用户名：</th>
                <td>
                    <input type="text" class="lg" name="name" value="{{ old('name') }}">
                </td>
            </tr>
            <tr>
                <th><i class="require">*</i> 邮箱：</th>
                <td>
                    <input type="text" class="lg" name="email" value="{{ old('email') }}">
                </td>
            </tr>

            <tr>
                <th><i class="require">*</i> 密码：</th>
                <td>
                    <input type="password" style="width:190px" class="lg" name="password">
                </td>
            </tr>


            <tr>
                <th><i class="require">*</i> 确认密码：</th>
                <td>
                    <input type="password" style="width:190px" class="lg" name="password_confirmation">
                </td>
            </tr>
            <tr class="addroles">
                <th width="120">所属角色：</th>
                <td>
                    <select name="role_id[]" style="width:200px;">
                        <option value="">角色不限</option>
                        @foreach($roles as $v)
                            <option value="{{$v->id}}">[{{$v->name}}]{{$v->display_name}}</option>
                        @endforeach
                    </select>
                    <input type="button" id="addonerole" onclick="addOneRole(this)" value="添加一个角色">
                </td>
            </tr>
            <tr id="subrole">
                <th></th>
                <td>
                    <img src="" alt="" id="art_thumb_img" style="max-width: 350px; max-height:100px;">
                </td>
            </tr>

            <tr>
                <th></th>
                <td>
                    <input type="submit" value="提交">
                    <input type="button" class="back" onclick="history.go(-1)" value="返回">
                </td>
            </tr>
            </tbody>
        </table>
    </form>
</div>
@endsection

@section('footerjs')
    @parent
    {{--//添加一个角色--}}
    <script type="text/JavaScript">
        function addOneRole(othis) {
            var obj = $(othis).parents('tr').clone();
            obj.find('#addonerole').remove();
            if ($('.addroles').size() <= 3) {
                $('#subrole').before(obj);
            } else {
                layer.msg('角色属性个数不能大于4个', {icon: 5});
            }
        }
    </script>
@show


